import random

import mysql

my = mysql.MYSQL(host='www.rthacker.top', user='test', password='Test@123', db='test')


def main():
    q = my.query('select * from device')
    for line in q:
        print(line)


def insert():
    # info = ['A1', 'A2', 'A3', 'B1', 'B2', 'B3']
    # for i, v in enumerate(info):
    #     my.update('insert into cabinet values ({}, "{}")'.format(i, v))

    # info = ['服务器', '交换机', '防火墙', '存储']
    # for i in range(1, len(info)):
    #     for j in range(1, 10):
    #         my.update('insert into device values (0, "{}", "1-2", {}, {}, {})'.format(info[i] + str(j), random.randint(0, 6), random.randint(0, 1), round(time.time())))

    for i in range(7, 20):
        for _ in range(5):
            my.update('insert into maintenence values ({},{},"{}",{})'.format(i, random.randint(0, 1), '第一次巡检', 16194 * 10000 + random.randint(1, 20862)))


def query():
    q = my.query('select * from device')
    for line in q:
        print(line)


if __name__ == '__main__':
    insert()